<!DOCTYPE html>
<html>
<head>
    <title>题目表</title>
		<#include "/header.html">
</head>
<body>
<div id="rrapp" v-cloak>
    <div v-show="showList">
        <div class="grid-btn">
            <i-col span="4">
                <i-select v-model="q.subjectId" filterable placeholder="题库选择">
                    <i-option v-for="item in subjectListByQues" :value="item.id"
                              :key="item.id">{{item.subjectName}}
                    </i-option>
                </i-select>
            </i-col>

            <i-col span="4" style="margin-left: 10px">
                <i-input v-model="q.name" @on-enter="query" placeholder="题目内容"/>
            </i-col>
            <i-button class="btn btn-primary" @click="query">查询</i-button>
            <div style="display: block;float: right">
			<#if shiro.hasPermission("lanling:question:save")>
            <a class="btn btn-primary" @click="add"><i class="fa fa-plus"></i>&nbsp;新增</a>
			</#if>
			<#if shiro.hasPermission("lanling:question:update")>
            <a class="btn btn-primary" @click="update"><i class="fa fa-pencil-square-o"></i>&nbsp;修改</a>
			</#if>
			<#if shiro.hasPermission("lanling:question:delete")>
            <a class="btn btn-primary" @click="del"><i class="fa fa-trash-o"></i>&nbsp;删除</a>
			</#if>
            </div>
        </div>
        <table id="jqGrid"></table>
        <div id="jqGridPager"></div>
    </div>

    <div v-show="!showList" class="panel panel-default">
        <div class="panel-heading">{{title}}</div>
        <i-form ref="formValidate" :model="question" :rules="ruleValidate" :label-width="80" class="form-horizontal">
            <Form-item label="请选择科目" prop="subjectId">
                <i-select v-model="question.subjectId" filterable label-in-value>
                    <i-option v-for="item in subjectList" :value="item.id"
                              :key="item.id">{{item.subjectName}}
                    </i-option>
                </i-select>
            </Form-item>
            <Form-item label="题目类型" prop="questionType">
                <Radio-group v-model="question.questionType" @on-change="questionTypeChange">
                    <Radio label="1">
                        <span>普通题目</span></Radio>
                    <Radio label="2">
                        <span>图片题目</span></Radio>
                    <Radio label="3">
                        <span>视频题目</span></Radio>
                </Radio-group>
            </Form-item>
            <Form-item v-if="showImgUrl" label="题目图片" prop="imgUrl">
                <i-col span="16">
                    <i-input v-model="question.imgUrl" placeholder="题目图片" readonly/>
                </i-col>
                <i-col span="3">
                    <Form-item :label-width="1">
                        <Upload style="width: 300px;" action="../../sys/oss/upload" :format="['jpg','jpeg','png']"
                                max-size="2048"
                                :on-success="handleSuccessPicUrl" :on-format-error="handleFormatError"
                                :show-upload-list="false"
                                :on-exceeded-size="handleMaxSize">
                            <i-button icon="ios-cloud-upload-outline">上传图片</i-button>
                        </Upload>
                    </Form-item>
                </i-col>
                <i-col span="3">
                    <Form-item :label-width="1">
                        <i-button icon="eye" @click="eyeImagePicUrl">预览图片</i-button>
                    </Form-item>
                </i-col>
            </Form-item>
            <Form-item v-if="showVideoUrl" label="题目视频" prop="videoUrl">
                <i-col span="16">
                    <i-input v-model="question.videoUrl" placeholder="题目视频" readonly/>
                </i-col>
                <i-col span="3">
                    <Form-item :label-width="1">
                        <Upload style="width: 300px;" action="../../sys/oss/upload" :format="['mp4']"
                                max-size="20480"
                                :on-success="handleSuccessVideoUrl" :on-format-error="handleVideoFormatError"
                                :show-upload-list="false"
                                :on-exceeded-size="handleVideoMaxSize">
                            <i-button icon="ios-cloud-upload-outline">上传视频</i-button>
                        </Upload>
                    </Form-item>
                </i-col>
            </Form-item>
            <Form-item label="题目内容" prop="questionContent">
                <i-input type="textarea" :rows="4" v-model="question.questionContent" placeholder="题目内容"/>
            </Form-item>
            <Form-item label="选项类型" prop="optionType">
                <Radio-group v-model="question.optionType">
                    <Radio label="1">
                        <span>单选题</span></Radio>
                    <Radio label="2">
                        <span>多选题</span></Radio>
                    <Radio label="3">
                        <span>判断题</span></Radio>
                </Radio-group>
            </Form-item>
            <Form-item label="选项内容" prop="optionContent">
                <i-input type="textarea" :rows="4" v-model="question.optionContent" placeholder="选项内容"/>
            </Form-item>
            <Form-item label="正确答案" prop="trueAnswer">
                <i-input v-model="question.trueAnswer" placeholder="正确答案"/>
            </Form-item>
            <!--<Form-item label="创建人" prop="createBy">-->
                <!--<i-input v-model="question.createBy" placeholder="您的姓名"/>-->
            <!--</Form-item>-->
            <Form-item label="备注" prop="remark">
                <i-input type="textarea" :rows="4" v-model="question.remark" placeholder="备注"/>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>
                返回</i-button>
            </Form-item>
        </i-form>
    </div>
    </div>
</div>

<script src="${request.contextPath}/statics/js/modules/lanling/question.js?_${.now?long}"></script>
</body>
</html>